package com.itheima.demo.deadlock;

public class Test01 {//用Lambda表达式创建死锁
    public static void main(String[] args) {
        //创建两个对象
        Object obj1 = new Object();
        Object obj2 = new Object();

        new Thread(()->{
            while(true){
                synchronized(obj1){
                    synchronized (obj2){
                        System.out.println("小薇同学在中路");
                    }
                }
            }
        }).start();

        new Thread(()->{
            while(true){
                synchronized(obj2){
                    synchronized (obj1){
                        System.out.println("尔康同学在走路");
                    }
                }
            }
        }).start();
    }
}
